package com.cookbook.service.impl;

import com.cookbook.database.data.UserMapper;
import com.cookbook.database.model.User;
import com.cookbook.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	UserMapper userMapper; //spring框架配置了注解，自动注入

	@Override
	public void insert(User user) throws Exception {
		userMapper.insert(user);
	}

	@Override
	public User selectWithId(int id) throws Exception {
		return userMapper.selectWithId(id);
	}

	@Override
	public User findUserByUsername(String username) throws Exception {
		return userMapper.selectWithUsername(username);
	}
}
